package com.awesome.todo;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * This is the User class. It is just a Java-object representation of a row from our 
 * User table.
 * 
 * @author Emily Cheatham
 *
 */

public class User {
	
	String name;
	String password;
	String email;
	String login;
	Long id;
	
	public User(String name, String login, String email, String password) {
		this.login = login;
		this.name = name;
		this.password = password;
		this.email = email;
		
	}
	
	public User() {
		this(null, null, null, null);
	}
	
	/**
	 * Uses regex to check if the given string is a valid email.
	 * @param email the email string to test
	 * @return true if a valid email
	 */
	public static boolean validEmail(String email) {
	
        // TODO - TEST THIS METHOD!

		Pattern p = Pattern.compile(".+@.+\\.[a-z]+");
		Matcher m = p.matcher(email);
		
		return m.matches();
		
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public void setPassword(String password) {
		this.password = password;
	}
	
	public void setEmail(String email) {
		this.email = email;
	}
	
	public void setLogin(String login) {
		this.login = login;
	}
	
	public void setId(Long id) {
		this.id = id;
	}
	
	public String getName() {
		return name;
	}
	
	public String getEmail() {
		return email;
	}
	
	public String getLogin() {
		return login;
	}
	
	public String getPassword() {
		return password;
	}
	
	public Long getId() {
		return id;
	}
	
}
